﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _88抽象图形类
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Rect r1 = new Rect() { l = 3, w = 4 };
            Rect r2 = new Rect() { l = 4, w = 5 };
            Circle c1 = new Circle() { r = 1 };

            Graphic[] graphics = { r1, r2, c1 };

            //....
        }
    }

    internal abstract class Graphic
    {
        public abstract float GetArea();
        public abstract float GetPremeter();
    }

    internal class Rect : Graphic
    {
        public float l;
        public float w;
        public override float GetArea()
        {
            return l * w;
        }

        public override float GetPremeter()
        {
            return (l + w) * 2;
        }
    }

    internal class Circle : Graphic
    {
        public float r;
        public override float GetArea()
        {
            return (float)Math.PI * r * r;
        }

        public override float GetPremeter()
        {
            return (float)Math.PI * r * 2;
        }
    }
}